<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <meta http-equiv="x-ua-compatible" content="ie=edge" />
    <include file="./Public/Admin/header.html" />
</head>
<body>

<div id="main">
    <div class="container-fluid">

        <div class="row-fluid">
            <div class="span12">
                <div class="box">
                    <div class="box-title">
                        <div class="span10">
                            <h3><i class="icon-edit"></i>编辑系统菜单</h3>
                        </div>
                        <div class="span2"><a class="btn" href="javascript:window.history.go(-1)">返回</a></div>
                    </div>

                    <div class="box-content">


                        <form action="{:U('Admin/Permission/addmenus')}" method="post" class="form-horizontal form-validate">
                            <div class="control-group">
                                <label for="sys_menu_name" class="control-label">菜单所属：</label>
                                <div class="controls">
                                    <select id="parent_id" name="parent_id">
                                        <?php if($menus['parent_id']!=''){?>
                                        <option value="<?php echo $menus['parent_id'];?>">
                                            <?php
                                                
                                                        if($menus['parent_id']=='0')
                                                        {
                                                            echo '--一级菜单--';
                                                        }else{
                                            $mns=M('sys_menu')->where(array('sys_menu_id'=>$menus['parent_id']))->find();
                                            if(count($mns)>0)
                                            {
                                            echo $mns['sys_menu_name'];
                                            }
                                            }
                                            ?>
                                        </option>
                                        <?php }else{?>
                                        <option value="0">--一级菜单--</option>
                                        <?php }?>
                                        <?php
                                                $ms=M('sys_menu')->where(array('parent_id'=>0))->order('sort_num asc')->select();
                                        if(count($ms)>0): foreach($ms as $item):
                                        ?>
                                        <option value="<?php echo $item['sys_menu_id'];?>"><?php echo $item['sys_menu_name'];?></option>
                                        <?php
                                        $ejmenus=M('sys_menu')->where(array('parent_id'=>$item['sys_menu_id']))->order('sort_num asc')->select();
                                        if(count($ejmenus)>0):foreach($ejmenus as $ej):
                                        ?>
                                        <option value="<?php echo $ej['sys_menu_id'];?>">├<?php echo $ej['sys_menu_name'];?></option>
                                        <?php endforeach;endif;?>
                                        <?php endforeach;endif;?>
                                    </select>
                                </div>
                            </div>
                            <div class="control-group">
                                <label for="sys_menu_name" class="control-label">菜单名称：</label>
                                <div class="controls">
                                    <input type="text" name="sys_menu_name" id="sys_menu_name" class="input-medium" value="<?php echo $menus['sys_menu_name']?>" data-rule-required="true"/><span class="maroon">*</span>
                                </div>
                            </div>
                            <div class="control-group">
                                <label for="link_url" class="control-label">链接：</label>
                                <div class="controls">
                                    <input type="text" name="link_url" id="link_url" class="input-medium" value="<?php echo $menus['link_url']?>"/>
                                </div>
                            </div>
                            <div class="control-group">
                                <label for="sort_num" class="control-label">排序：</label>
                                <div class="controls">
                                    <input type="text" name="sort_num" id="sort_num" class="input-medium "  value="<?php echo $menus['sort_num']?>">
                                </div>
                            </div>

                            <div class="form-actions">
                                <input type="hidden" name="action" id="action" value="<?php echo $action?>"/>
                                <input type="hidden" name="sys_menu_id" id="sys_menu_id" value="<?php echo $sys_menu_id?>"/>
                                <button type="submit" class="btn btn-primary">保存</button>
                                <a class="btn" href="javascript:window.history.go(-1)">取消</a>

                            </div>
                        </form>
                    </div>
                </div>
            </div>

        </div>
    </div>
</div>
<script type="text/javascript">
    $(function(){
        $('#sys_user_name').focus();
    });
</script>
</body>
</html>